package com.zjs.timing;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * springboot定时任务
 * 默认条件注解是开启的，现在通过ConditionalOnProperty采用配置文件的变量来手动控制定时任务是否执行
 * @author zhu_jinsheng
 * @version 1.0
 * @date 2020/7/6 14:29
 */
@Slf4j
@Service
@ConditionalOnProperty(prefix = "scheduling", name = "enabled", havingValue = "true")
public class ScheduledTask {

    /**
     * 静态的定时任务
     */
    @Scheduled(fixedRate = 5000)
    public void simpleTask(){
        log.info("current run by simpleTask");
    }

}
